//
//  NearByCellClickDetailTableViewCell.m
//  VTravel
//
//  Created by lanouhn on 16/8/6.
//  Copyright © 2016年 xiaoYu. All rights reserved.
//

#import "NearByCellClickDetailTableViewCell.h"

@implementation NearByCellClickDetailTableViewCell

// "timetables" = ({"date_time" = 2016-08-08,},{"date_time" = 2016-08-09,},{"date_time" = 2016-08-10,},{"date_time" = 2016-08-11,},{"date_time" = 2016-08-12,},{"date_time" = 2016-08-13,},),
//  "wl_tags" = ({"tag_name" = 休闲度假,},),

- (void)setModel:(NearByCellClickDetailModel *)model{
    
    [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:model.thumb]];
    self.titleLabel.text = model.product_name;
    NSString *str1 = @"";
    for (int i = 0; i < model.timetables.count; i++) {
        NSString *str2 = [model.timetables[i][@"date_time"] substringWithRange:NSMakeRange(0, 5)];
       NSString *str = [[model.timetables[i][@"date_time"] componentsSeparatedByString:str2] lastObject];
       str1 = [str1 stringByAppendingString:[NSString stringWithFormat:@"%@、", str]];
    }
    self.dateLabel.text = [NSString stringWithFormat:@"%@出发", str1];
    self.priceLabel.text = [NSString stringWithFormat:@"¥%@起",model.adult_price];
    self.payStyleLabel.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.8];
    if ([model.parent_pay_way isEqualToString:@"2"]) {
        self.payStyleLabel.text = @"确认后支付";
    }else if ([model.pay_way isEqualToString:@"1"]){
        self.payStyleLabel.text = @"直接支付";
    }
    if (model.wl_tags.count != 0) {
        UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(8, 0, 60, 20)];
        textField.text = model.wl_tags[0][@"tag_name"];
        textField.textColor = [UIColor orangeColor];
        textField.borderStyle = UITextBorderStyleLine;
        textField.textAlignment = NSTextAlignmentCenter;
        textField.layer.borderColor = [UIColor orangeColor].CGColor;
        textField.layer.borderWidth = 2;
        textField.font = [UIFont systemFontOfSize:13];
        textField.enabled = NO;
        [self.detailView addSubview:textField];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
